<?php 
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require_once("include/config.php");
require_once("include/httpUtil.php");
header("Content-type: text/html; charset=utf-8");
define('SCRIPT','ad_list');
if(!$_COOKIE['userid']){
    echo "<script type='text/javascript'>location.href='mlogin.php';</script>";
    exit;
}

$sqlsm = "select * from tbl_shiming where userid=".$_COOKIE['userid'];
$querysm=mysql_query($sqlsm);
$rowsm=mysql_fetch_array($querysm);
if($rowsm){
$ifshiming="1";
}else {
$ifshiming="2";		
}



?> 
<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1">
  <title>技能发布-众晒网</title>
  <meta name="renderer" content="webkit">
    <!-- Set render engine for 360 browser -->


  <!-- No transcoding by search engine-->
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp"/>
  <link rel="stylesheet" href="/ui/amui/css/amazeui.min.css">
    <link rel="stylesheet" href="/ui/amui/css/app.css">
<script src="/ui/amui/js/jquery.min.js"></script>
<script src="/ui/amui/js/amazeui.min.js"></script>
<link rel="stylesheet" href="/ui/amui/di/dist/amazeui.address.min.css">
<script src="/ui/amui/di/dist/iscroll.min.js">
</script> <script src="/ui/amui/css/address.js"></script>
<script type="text/javascript" src="/ui/layer/mobile/layer.js"></script>  
<style type="text/css">
.am-input-group-warning .am-input-group-btn>.am-btn, .am-input-group-warning .am-input-group-label, .am-input-group-warning.am-input-group .am-form-field {
    border-color: #efa10000;
    border: 0;
    border-bottom: 1px solid #CCCCCC;
}
body {
    background: #f7f7f7;
}
.am-padding-sm {
    .am-padding-sm {
    padding-left: 0px;
    padding-right: 0px;
}
.am-padding-sm {
    padding: 0px;
}
textarea#ziwop {
    font-size: 14px;
}
.am-input-group {
    background: #ffffff;
}
.am-selected-status {
   
    padding: 0;
   
}
</style>
</head>
<body  style="margin-top:-25px">
<div class="am-alert am-alert-warning" style="margin-top:23px;background-color: #ffffff;"> 
  <button type="button" onclick="disp_confirm()" class="am-close" style="color: black;">&times;</button>
  <p style="color: black;text-align: center;">技能发布</p>
</div>

  <div style="display:none">
            <input type="hidden" name="infoid" value="<?php echo time().rand(100,999);?>" />  
				<input type="hidden" name="lat" id="lat" value="" />
	
	             <input type="hidden" name="lng" id="lng" value="" />	

	            <input type="hidden" name="city" id="city" value="" />	
				
	            <input type="hidden" name="is_business3" id="is_business3" value="" />	
				
	            <input type="hidden" name="is_home" id="is_home" value="0" />	
				
	            <input type="hidden" name="is_shop" id="is_shop" value="0" />					
        </div>  
       <div >
       <center>
            <div style="width:70px;height:70px;margin:0 auto;" onclick="getElementById('inputfile').click()">
            <div style="float:left;width:70px;height:70px;margin:0 auto;" >
            <img src="/ui/image/圆角矩形1141拷贝3@3x.png"  style="width:67px;height:67px;" alt="" title="添加照片">
            <input type="file" accept="image/*" multiple="multiple" id="inputfile" style="height:0;width:0;z-index: -1; position: absolute;left: 10px;top: -100px;"/>
            </div>
            </div>	
        </center>  
        </div>
            <div id="feedback"  value="feedback" name="ywyuedu" style="margin-bottom:10px">
            <input style=" display:none" id="srcall" name="ywyuedu">
        </div>
<div class="am-input-group am-input-group-warning am-padding-sm" style="width:100%;margin:0; padding:0; border: 0;">
  <input type="text" name="title" id="title" style="width: 100%" class="am-form-field" placeholder="清晰明确的标题更吸引人">
</div>

<div class="am-input-group am-input-group-warning am-padding-sm am-round" style="width:100%; padding: 0">

  <textarea name="ziwop" id="ziwop" type="text" rows="5" cols="7" style="border-radius:5px 5px 5px 5px; border: 0; height:185px; font-size: 14px;" class="am-form-field"  placeholder="请输入您的收费标准.服务流程.服务保障等。详细的服务介绍可以吸引更多客户阅读"></textarea>
</div>
<div style="line-height: 0.6;">
			<div style="width:100%">
			<fieldset class="am-form-set" style="width:63%;margin-top:-23px;height:33px">
				<input type="text" name="allcity" id="allcity"  readonly style="top:20px;padding:.55em;border:0;margin-left: 100px;background-color:rgba(255, 255, 255, 0); font-size: 0.875rem;">
			</fieldset>			
			<button type="button" id="address2" class="am-btn am-btn-block am-margin-bottom-sm"	style="width:100%; height: 35px; float:left;margin-top:-27px;background-color: #ffffff;color:black; text-align: left; font-size: 0.875rem;width: 100%;">
				&nbsp;&nbsp;位置
			</button>

			</div>
			
<div class="am-input-group" style="width: 100%;">
  <span class="am-input-group-label">详细地址:</span>
  <input type="text" name="fulladdre" id= "fulladdre"  class="am-form-field" placeholder="请输入详细地址" style="border: 0">
</div>

<select name="service_age_range" id="service_age_range" data-am-selected="{btnWidth: '100%', btnSize: 'sm', btnStyle: 'warning',dropUp: 1}">
  <option value ="none">个人工作经验</option>
  <option value ="0">1-2年</option>
  <option value ="1">3-5年</option>
  <option value ="2">5-7年</option>
  <option value ="3">8-10年</option>
  <option value ="4">10年以上</option>

</select>
      


<div class="am-input-groupclass">
<div style="margin-top:5px;"></div>
<select name="fenlei" id="fenlei" data-am-selected="{btnWidth: '100%', btnSize: 'sm', btnStyle: 'warning',dropUp: 1}">
  <option value ="0">顶级分类</option>
   <?php 
       $sql_cat = "select * from tbl_skill_catgroy where status=0  order by id asc";
       $query_cat = mysql_query($sql_cat);
       while ($row_cat=mysql_fetch_array($query_cat)) { 
   ?> 
       <option value ="<?php echo $row_cat['id']; ?>"><?php echo $row_cat['cat_name']; ?></option>
   <?php } ?>  
</select>
<style type="text/css">
.am-btn-warning {
    color: #000;
    background-color: #ffffff;
    border-color: #ffffff;
}
.am-input-group-label {
    
    font-size: 0.875rem;
    
    color: #000;
    border: 0px solid #ccc;
    /* border-radius: 4px; */
    background: #ffffff;
}
.am-input-group {
    background: #fff;
}
.am-ucheck-checkbox:checked+.am-ucheck-icons, .am-ucheck-radio:checked+.am-ucheck-icons {
    color: #ffa200;
}
.am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons, .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons {
    color: #ffa200;
}
.am-form-group {
    line-height: 30px;
}
</style>

</div>

<br/>

<div class="am-input-group" style="width: 100%;">
  <span class="am-input-group-label">服务收费:</span>
  <input type="number" name="price" id= "price"  class="am-form-field" placeholder="请输入价格" style="border: 0">
  <span class="am-input-group-label">元</span>
</div>

<div class="am-input-group" style="width: 100%;">
  <span class="am-input-group-label">服务类型：</span>
  <label   class="am-checkbox-inline" style="margin-top: 10px;">
    <input  id="shangmeng" type="checkbox" onclick="showdiv()" value="" data-am-ucheck> 上门
  </label>
  &nbsp;&nbsp;&nbsp;
  <label class="am-checkbox-inline"  style="margin-top: 10px;">
    <input type="checkbox"  id="daodian" value="" onclick="is_shop()" data-am-ucheck> 到店（可多选）
  </label>
</div>

<div  class="am-input-group" style="width: 100%; height: 50px; display: none;" id="feiyong">
  <span class="am-input-group-label" style="float: left; width: 22%;">上门费用:</span>
  <input type="text" name="num" id= "to_home_money"  class="am-form-field" placeholder="请输入价格" style="border: 0; float: left; width: 70%;">
  <span class="am-input-group-label" style="float: left; width: 8%;">元</span>
</div>

<!----------------
<div class="am-input-group" style="width: 100%;">
  <span class="am-input-group-label">服务年龄段:</span>
  <input type="text" name="num" id= "age_range"  class="am-form-field" placeholder="请手动输入，如50" style="border: 0">
</div>
------------------>
<select name="age_range" id="age_range" data-am-selected="{btnWidth: '100%', btnSize: 'sm', btnStyle: 'warning',dropUp: 1}">
  <option value ="none">服务年龄段</option>
  <option value ="0">0-6个月</option>
  <option value ="1">6-12个月</option>
  <option value ="2">1-3岁</option>
  <option value ="3">4-8岁</option>
</select>




<center>
      <div class="am-input-group" style="width:100%; height: 35px; background: #fff;">
        <span style="float: left; font-size: 15px; margin-left: 13px; line-height: 35px;">发布者：</span>
        <div class="am-form-group" >
							<?php if($ifshiming==2){ ?>
          <label class="am-radio-inline" style="margin-top: 0;">
            <input type="radio" name="radio10" value="male" onclick="showt()" data-am-ucheck > 商家
          </label>
		  					<?php } ?>
							
		  					<?php if($ifshiming==1){ ?>
          <label class="am-radio-inline" style="margin-top: 0;">
            <input type="radio" name="radio10" onclick="is_business1()" value="male" data-am-ucheck > 商家
          </label>	
		  					<?php } ?>
		  
          <label class="am-radio-inline">
            <input type="radio" name="radio10" value="is_business0" onclick="is_business0()"  data-am-ucheck> 个人
          </label>
  
        </div>
      </div>
      
</center>
    <script>  
        if (navigator.geolocation){  

            navigator.geolocation.getCurrentPosition(  

                function( position ) {    

                    show_msg( position );  

                 },  

                function( err ) {  

                    switch(error.code){  
                    case 0:  
                      alert("尝试获取您的位置信息时发生错误：" + error.message);  
                      break;  
                    case 1:  
                        alert("用户拒绝了获取位置信息请求。");  
                      break;  
                    case 2:  
                        alert("浏览器无法获取您的位置信息：" + error.message);  
                      break;  
                    case 3:  
                        alert("获取您位置信息超时。");  
                      break;  
                    }  
                }  
       )}else  
          alert( '您当前使用的浏览器不支持Geolocation服务' );  


        function show_msg( position ){  

            var lat = position.coords.latitude;

            var lng = position.coords.longitude; 
            $("#lat").val(lat);
			$("#lng").val(lng);
			
           // alert( "您所在的位置： 经度" +  + "，纬度" + lng );  
            if( typeof position.address != "undefined" ){  

                var country = position.address.country; 

                var province = position.address.region;

                var city = position.address.city;  

               // alert(' 您位于 ' + country + province + '省' + city +'市');  
            }  
			
			  var latlon = position.coords.latitude+','+position.coords.longitude; 
 
  //baidu
  var url = "http://api.map.baidu.com/geocoder/v2/?ak=C93b5178d7a8ebdb830b9b557abce78b&callback=renderReverse&location="+latlon+"&output=json&pois=0"; 
  $.ajax({ 
    type: "GET", 
    dataType: "jsonp", 
    url: url, 
      beforeSend: function(){ 
       
		console.log('正在定位...');
      }, 
      success: function (json) { 
        if(json.status==0){ 
         // $("#baidu_geo").html(json.result.formatted_address); 
		 // alert(json.result.addressComponent.city);
		 $("#city").val(json.result.addressComponent.city);
         $("#city1").val(json.result.addressComponent.city);		 
        } 
      }, 
      error: function (XMLHttpRequest, textStatus, errorThrown) { 
        $("#baidu_geo").html(latlon+"地址位置获取失败"); 
    } 
  });
				
        }  
    </script> 
<script type="text/javascript">

function showt(){
  s=1;
 
if(s==1){//如果show是隐藏的
 
alert('请完成商户认证');
 location.href="shengjiqy.php";
 
}
 
}
function is_business0(){
	
$("#is_business3").val('0');	
	
}

function is_business1(){
	
$("#is_business3").val('1');	
	
}



</script>
</div>
<button type="button" onclick="clicimg()" class="am-btn am-btn-warning am-padding-sm" style="width: 88%; margin-left:6%;  margin-top: 75px; color: #ffffff; background: #ffa200;  bottom: 0px; font-weight: 800; border: 0;">确认发布</button>


<div style="margin-top:15px;"> </div>
		<script type="text/javascript">
			$(function() {
				document.addEventListener('touchmove', function (e) {
					e.preventDefault();
				}, false);
				//	自定义输出
				$("#address1").address({
					customOutput: true,
					selectEnd: function(json,address) {
						for(var key in json) {
							$("#address1-form").find("input[name='" + key + "']").val(json[key]);
						}
					}
				}).on("provTap",function(event,activeli){
					console.log(activeli.text());
				}).on("cityTap",function(event,activeli){
					console.log(activeli.text());
				})
				
				//	带底部的
				$("#address2").address({
					prov: "广东省",
					city: "清远市",
					district: "阳山县",
					scrollToCenter: true,
					footer: true,
					selectEnd: function(json) {
						//console.log(JSON.stringify(json));
                    //var addre=JSON.stringify(json);
					var JSON = eval(json); 
                     var cityall=JSON.prov+''+JSON.city+''+JSON.district;
					//alert(cityall);
						$("#allcity").val(cityall);
					}
				});
				
				//	配置级联层数
				$("#address3").address({
					prov: "广东省",
					city: "中山市",
					scrollToCenter: true,
					selectNumber: 2,
				});
				
				//	配置级联层数
				$("#address4").address({
					prov: "海南省",
					scrollToCenter: true,
					selectNumber: 1,
				});

			});
		</script>
<script type="text/javascript">
$(document).ready(function(){
    //响应文件添加成功事件
    $("#inputfile").change(function(){
        //创建FormData对象
        var data = new FormData();
        //为FormData对象添加数据
        $.each($('#inputfile')[0].files, function(i, file) {
            data.append('upload_file'+i, file);
        });
        $(".loading").show();   //显示加载图片
        //发送数据
        $.ajax({
            url:'submit_form_process.php',
            type:'POST',
            data:data,
            cache: false,
            contentType: false,     //不可缺参数
            processData: false,     //不可缺参数
            success:function(data){
                data = $(data).html();
                //alert(data);
                //第一个feedback数据直接append，其他的用before第1个（ .eq(0).before() ）放至最前面。
                //data.replace(/&lt;/g,'<').replace(/&gt;/g,'>') 转换html标签，否则图片无法显示。
                if($("#feedback").children('img').length == 0) $("#feedback").append(data.replace(/&lt;/g,'<').replace(/&gt;/g,'>'));
                else $("#feedback").children('img').eq(0).before(data.replace(/&lt;/g,'<').replace(/&gt;/g,'>'));
                $(".loading").hide();   //加载成功移除加载图片
            },
            error:function(){
                alert('上传出错');
                $(".loading").hide();   //加载失败移除加载图片
            }
        });
    });
});
</script>
<script type="text/javascript">
    function clicimg(){
        var legth=document.getElementsByName('thissrc');
        var srca="";
        for(var i=0;i<legth.length;i++){
            srca+=legth[i].src;
            srca+=",";
        }
        document.getElementById('srcall').value=srca;
	var uid='<?=$_COOKIE['userid']?>';
	var pics= document.getElementById('srcall').value;

	var title= $("#title").val();
	var details= $("#ziwop").val();	
	var cat_id= $("#fenlei").val();		
	var price= $("#price").val();		
	var lat= $("#lat").val();		
	var lng= $("#lng").val();		
	var city= $("#city").val();		
	var service_age_range= $("#service_age_range").val();		
	var age_range= $("#age_range").val();		
	var is_home= $("#is_home").val();	
	var is_business3= $("#is_business3").val();	
	var is_shop= $("#is_shop").val();	
	var to_home_money= $("#to_home_money").val();		
    console.log(pics);
    console.log(title);
    console.log(details);
    console.log(price);
    console.log(city);
    console.log(service_age_range);
    console.log(age_range);
    console.log(cat_id);
    console.log(is_home);
    console.log(is_business3);
    console.log(is_shop);	
    console.log(to_home_money);	
	
	if(uid==""){
	layer.open({
    content: '请先登录'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}
	
	if(pics==""){
	layer.open({
    content: '请上传照片'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}
	
	if(title==""){
	layer.open({
    content: '请填写标题'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}
	
	if(details==""){
	layer.open({
    content: '请填写技能文章详情'
    ,skin: 'msg'
    ,time: 2 
  });
	return false;  
	}	
	
	if(cat_id==""){
	layer.open({
    content: '请选择分类'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}
	
	if(price==""){
	layer.open({
    content: '请输入价格'
    ,skin: 'msg'
    ,time: 2 
  });
	return false;  
	}	
	
	if(service_age_range==""){
	layer.open({
    content: '请输入价格'
    ,skin: 'msg'
    ,time: 2 
  });
	return false;  
	}	

	if(service_age_range==""){
	layer.open({
    content: '请输入价格'
    ,skin: 'msg'
    ,time: 2 
    });
	return false;	
	}
	
	if(age_range==""){
	layer.open({
    content: '请输入服务年龄段'
    ,skin: 'msg'
    ,time: 2 
    });
	return false;	
	}	

	if(is_business3==""){
	layer.open({
    content: '请选择个人或者商家'
    ,skin: 'msg'
    ,time: 2 
    });
	return false;
	}
	

	
    $.ajax({
    url: '/api/muyin/api.php?s=skill.save_skill_detail',
    type: 'POST',
    dataType: 'json',
    data: {uid: uid,
	title:title,
	details:details,
	cat_id:cat_id,
	price:price,
	lat:lat,
	lng:lng,
	pics:pics,
	city:city,
	service_age_range:service_age_range,
	age_range:age_range,
	is_business3:is_business3,
	is_home:is_home,
	is_shop:is_shop,
	to_home_money:to_home_money
	},
      })
     .done(function(respon) {
     if (respon.code==0) {
     layer.open({
    content: '发布成功'
    ,btn: ['知道了']
    ,yes: function(index){
      window.location.href="index.php";
      layer.close(index);
    }
  });
                                      
   }else{
                                            
   alert('再试一次');
    }
    })	
 }	
</script>	
<script type="text/javascript">
$(function () {  
            //防止页面后退  
            history.pushState(null, null, document.URL);  
            window.addEventListener('popstate', function () {  
                    history.pushState(null, null, document.URL);  
            });  
        }) 
</script>
<script type="text/javascript">
function disp_confirm()
  {
  var r=confirm("确定返回将不保存您编辑的内容")
  if (r==true)
    {
     window.location.href="index.php"
    }
  }
</script>	
<script type="text/javascript">

function showdiv(){
 
if($("#feiyong").css("display")=='inline'){//如果show是隐藏的
 
$("#feiyong").css("display","none");//show的display属性设置为block（显示）
 
 $("#is_home").val('0');
}else{//如果show是显示的
 
$("#feiyong").css("display","inline");//show的display属性设置为none（隐藏）

$("#is_home").val('1');

 $("#to_home_money").val('0');
}
 
}

function is_shop(){
	
if($("#is_shop").val()=='0'){
 
$("#is_shop").val('1');
 
}else{
 
$("#is_shop").val("0");
 
}	
		
}

</script>

	<script>
	
	function del(c){
		console.log(c);
		
	  layer.open({
    content: '确定要删除当前照片吗？'
    ,btn: ['要', '不要']
    ,yes: function(index){
 
     $("#"+c).remove();
      layer.close(index);
    }
  });	
		
		

		
	}
	
	</script>


</body>
</html>
